<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('安全巡查基本信息列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <input type="hidden" name="assetsId" th:value="${id}" id="assetsId"/>
                            <input type="hidden" name="address" th:value="${address}" id="address"/>
                            <li>
                                <label>巡查人：</label>
                                <input type="text" name="name"/>
                            </li>
                            <li>
                                <label>巡查时间：</label>
                                <input type="text" class="time-input" placeholder="请选择巡查时间" name="patrolTime"/>
                            </li>
                            <li>
                                <label>是否存在安全隐患：</label>
                                <select name="existLoophole" th:with="type=${@dict.getType('exist_loophole')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>处理结果：</label>
                                <select name="dealResult" th:with="type=${@dict.getType('deal_result')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="add()" >
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:property:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:property:remove')}]];
        var existLoopholeDatas = [[${@dict.getType('exist_loophole')}]];
        var dealResultDatas = [[${@dict.getType('deal_result')}]];
        var assetsId = [[${id}]];
        var address = [[${address}]];
        var prefix = ctx + "system/property";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "安全巡查基本信息",
                columns: [{
                    checkbox: true
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                },
                {
                    field: 'id',
                    title: '主键ID',
                    visible: false
                },
                {
                    field: 'assetsId',
                    title: '房产或土地资产',
                    visible: false

                },
                {
                    field: 'address',
                    title: '巡查地点'
                },
                {
                    field: 'name',
                    title: '巡查人名称'
                },
                {
                    field: 'patrolTime',
                    title: '巡查时间'
                },
                {
                    field: 'existLoophole',
                    title: '是否存在安全隐患',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(existLoopholeDatas, value);
                    }
                },
                {
                    field: 'remark',
                    title: '备注'
                },
                {
                    field: 'dealResult',
                    title: '处理结果',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(dealResultDatas, value);
                    },
                    visible: false
                },
                {
                    field: 'dealPerson',
                    title: '处理人',
                    visible: false
                },
                {
                    field: 'dealTime',
                    title: '处理时间',
                    visible: false
                },
                {
                    field: 'dealDescription',
                    title: '处理情况说明',
                    visible: false
                },
                {
                    field: 'dealWay',
                    title: '整改措施',
                    visible: false
                },
                {
                    field: 'charger',
                    title: '安全隐患责任单位'
                },
                {
                    field: 'dangerContent',
                    title: '隐患内容'
                },
                {
                    field: 'dangerType',
                    title: '隐患类别',
                    visible: false
                }
               ]
            };
            $.table.init(options);
        });

        function add(){
            $.modal.open("新增资产", prefix+"/addbyId/"+assetsId+"/"+address);
        }

    </script>
</body>
</html>